<template>
  <div>
    <!-- 头部导航栏 -->
    <div class="home_nav">
      <div class="home_left">
        <img
          src="https://ssr-static.msstatic.com/h5/mobile/@public-online/imgs/header/logo.acc780e7a19f22c1d8e89805488fcfef.png"
          alt=""
        />
      </div>
      <router-link tag="div" to="/search" class="home_right">
        <span class="iconfont icon-sousuo"></span>
      </router-link>
    </div>

    <!-- 关注 -->
    <div class="follow_live">订阅</div>

    <van-empty description="暂无订阅" v-if="tips" />

    <!-- 中间关注 -->
    <div class="follow_list" v-if="!tips">
      <router-link
        tag="div"
        :to="'/details?id=' + item.id"
        class="follow_item"
        v-for="item in follow_lists"
        :key="item.id"
      >
        <div class="follow_item_left">
          <div class="img">
            <img :src="item.img_head" alt="" />
          </div>
          <div class="name_title">
            <p>{{ item.name }}</p>
            <p>{{ item.title }}</p>
          </div>
        </div>
        <div class="follow_item_right">
          <img src="../assets/img/zibo.gif" alt="" />
          <span>直播间</span>
        </div>
      </router-link>
    </div>

    <!-- 正在直播 -->
    <div class="follow_live">正在直播</div>

    <!-- 直播人员 -->
    <div class="home_lists">
      <div class="home_lists_content">
        <router-link
          tag="div"
          :to="'/details?id=' + item.id"
          class="home_item"
          v-for="item in wzry"
          :key="item.id"
        >
          <div class="home_item_img">
            <img :src="item.img" alt="" />
            <p>{{ item.p }}</p>
          </div>
          <div class="home_item_title">{{ item.title }}</div>
          <div class="home_item_bottom">
            <div class="home_item_name">{{ item.name }}</div>
            <div class="home_item_hot">
              <div class="home_item_hot_img">
                <img
                  src="http://a.msstatic.com/huya/mobile/img/crowd_2017_97bb042.png"
                  alt=""
                />
              </div>
              <p>{{ item.hot }}</p>
            </div>
          </div>
        </router-link>
      </div>
    </div>

    <!-- 底部固定 -->
    <div class="home_bottom">
      <router-link tag="div" to="/home" class="home_bottom_item">
        <span class="iconfont icon-zhibo1"></span>
        <p>直播</p>
      </router-link>
      <router-link tag="div" to="/info" class="home_bottom_item">
        <span class="iconfont icon-zixun1"></span>
        <p>咨询</p>
      </router-link>
      <div class="home_bottom_item con">
        <span class="iconfont icon-guanzhu1"></span>
        <p>关注</p>
      </div>
      <router-link tag="div" to="/user" class="home_bottom_item">
        <span class="iconfont icon-wode"></span>
        <p>我的</p>
      </router-link>
    </div>
  </div>
</template>

<script>
import { getHomeData } from "../api/home.js";
export default {
  data() {
    return {
      wzry: null,
      follow_lists: null,
      tips: true,
    };
  },
  created() {
    getHomeData().then((data) => {
      this.wzry = data.wzry;
    });
    let follow_item = JSON.parse(window.localStorage.getItem("total"));
    this.follow_lists = follow_item.filter((item) => {
      return item.checked;
    });
    if (this.follow_lists.length >= 1) {
      this.tips = false;
    } else {
      this.tips = true;
    }
  },
};
</script>

<style lang="scss" scoped>
//直播人员
.home_lists {
  padding-bottom: 60px;
  .home_lists_top {
    padding: 10px;
    padding-bottom: 0;
    .home_lists_top_img {
      display: flex;
      align-items: center;
      img {
        width: 25px;
        height: 25px;
      }
      p {
        text-indent: 5px;
        font-size: 16px;
      }
    }
  }
  .home_lists_content {
    padding: 0 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .home_item {
      width: 48%;
      margin-top: 10px;
      .home_item_img {
        width: 100%;
        height: 99px;
        border-radius: 5px;
        overflow: hidden;
        position: relative;
        img {
          width: 100%;
          height: 100%;
        }
        p {
          font-size: 12px;
          position: absolute;
          top: 3px;
          right: 3px;
          padding: 2px 6px;
          vertical-align: middle;
          color: #eee;
          background: rgba(44, 49, 54, 0.7);
        }
      }
      .home_item_title {
        width: 100%;
        padding: 3px 0;
        font-size: 13px;
        color: #000;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: normal;
      }
      .home_item_bottom {
        display: flex;
        justify-content: space-between;
        height: 13px;
        line-height: 13px;
        font-size: 11px;
        color: #999;
        padding: 3px 0;
        .home_item_name {
          max-width: 40%;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          word-break: normal;
        }
        .home_item_hot {
          display: flex;
          align-items: center;
          .home_item_hot_img {
            width: 13px;
            height: 13px;
            margin-right: 6px;
            margin-top: -3px;
            img {
              width: 100%;
              height: 100%;
            }
          }
        }
      }
    }
  }
}

// 正在直播
.follow_live {
  padding: 0 15px;
  color: rgb(47, 47, 47);
  font-family: 黑体;
  font-weight: 700;
  font-size: 16px;
  margin-top: 10px;
}

// 中间关注
.follow_list {
  .follow_item {
    display: flex;
    padding: 15px;
    align-items: center;
    justify-content: space-between;
    .follow_item_left {
      display: flex;
      flex: 1;
      .img {
        width: 45px;
        height: 45px;
        border-radius: 50%;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .name_title {
        margin-left: 8px;
        flex: 1;
        p {
          &:nth-child(1) {
            padding: 3px;
            color: #1e1e1e;
            font-size: 14px;
            font-weight: 600;
            font-family: 黑体;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          &:nth-child(2) {
            font-size: 12px;
            color: #787a82;
            margin-top: 4px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }
    .follow_item_right {
      background-color: #ffa200;
      display: flex;
      align-items: center;
      padding: 0 5px;
      border-radius: 15px;
      margin-left: 8px;
      img {
        width: 12px;
      }
      span {
        font-size: 13px;
        color: #ffffff;
        text-align: center;
        margin-left: 2px;
        transform: scale(0.83, 0.83);
        line-height: 22px;
      }
    }
  }
}

// 底部固定
.home_bottom {
  display: flex;
  background-color: #ffff;
  padding: 10px 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  .home_bottom_item {
    width: 25%;
    display: flex;
    flex-direction: column;
    align-items: center;
    span {
      font-size: 20px;
    }
    p {
      margin-top: 3px;
    }
    &.con {
      color: #ffa200;
    }
  }
}
// 头部导航栏
.home_nav {
  display: flex;
  padding: 15px;
  justify-content: space-between;
  align-items: center;
  .home_left {
    width: 100px;
    height: 30px;
    background-size: 100% 100%;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .home_right {
    padding: 6px 14px;
    background-color: #f4f4f4;
    border-radius: 15px;
  }
  border-bottom: 1px solid #ededed;
}
</style>
